package com.xln.pojo;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("t_category")
public class Category {

    @TableId(value = "id",type = IdType.AUTO)
    private Long id;

    private String name;

    private String description;

    private Long parentId = 0L;

    private Integer orderNum = 0;

    private String icon;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    @TableField(exist = false)
    private List<Category> children;

    // 获取分类层级路径的方法（可选）
    public String getPath() {
        if (parentId == 0) {
            return name;
        }
        // 这里可以递归获取父分类名称，构建完整路径
        return "父分类 > " + name;
    }
}